﻿(function ($) {
    // The validator function
    $.validator.addMethod('dateismayor',
      function (value, element, param) {
          if (!value) {
              return true; // not testing 'is required' here!
          }
          var valueCompare = $.datepicker.parseDate('dd/mm/yy', $('#' + param.valuedatecompare).val());
          var actualValue = $.datepicker.parseDate('dd/mm/yy', value);
          return valueCompare < actualValue;
      });

    // The adapter to support ASP.NET MVC unobtrusive validation
    $.validator.unobtrusive.adapters.add('dateismayor', ['valuedatecompare'],
     function (options) {
         //         var params = {
         //             valuedatecompare: $.datepicker.parseDate("dd/mm/yy", options.params.valuedatecompare),
         //         };
         options.rules['dateismayor'] = options.params;
         if (options.message) {
             options.messages['dateismayor'] = options.message;
         }
     });
} (jQuery));

